package com.ruoyi.system.service.impl;


import java.util.List;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysLuMapper;

import com.ruoyi.system.service.ISysLuService;


/**
 * 测试Service业务层处理
 *
 * @author ruoyi
 * @date 2024-01-22
 */
@Service
public class SysLuServiceImpl implements ISysLuService
{
    @Autowired
    private SysLuMapper sysLuMapper;

    /**
     * 查询测试
     *
     * @param userId 测试主键
     * @return 测试
     */
    @Override
    public SysUser selectSysLuByUserId(Long userId) {
        return sysLuMapper.selectSysLuByUserId(userId);
    }

    /**
     * 查询测试列表
     *
     * @param sysUser 测试
     * @return 测试
     */
    @Override
    public List<SysUser> selectSysLuList(SysUser sysUser) {
        List<SysUser> sysUsers = sysLuMapper.selectSysLuList(sysUser);
        sysUsers.stream().forEach(user->{
            DateTime dateTime = DateUtil.offsetDay(user.getPwdTime(), 90);
            user.setPasswordExpireTime(dateTime.toJdkDate());
        });
        return sysUsers;
    }

    /**
     * 新增测试
     *
     * @param sysUser 测试
     * @return 结果
     */
    @Override
    public int insertSysLu(SysUser sysUser)
    {
        sysUser.setCreateTime(DateUtils.getNowDate());
        return sysLuMapper.insertSysLu(sysUser);
    }

    /**
     * 修改测试
     *
     * @param sysUser 测试
     * @return 结果
     */
    @Override
    public int updateSysLu(SysUser sysUser)
    {
        sysUser.setUpdateTime(DateUtils.getNowDate());
        return sysLuMapper.updateSysLu(sysUser);
    }

    /**
     * 批量删除测试
     *
     * @param userIds 需要删除的测试主键
     * @return 结果
     */
    @Override
    public int deleteSysLuByUserIds(Long[] userIds)
    {
        return sysLuMapper.deleteSysLuByUserIds(userIds);
    }

    /**
     * 删除测试信息
     *
     * @param userId 测试主键
     * @return 结果
     */
    @Override
    public int deleteSysLuByUserId(Long userId)
    {
        return sysLuMapper.deleteSysLuByUserId(userId);
    }
}
